<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('任务列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>任务名称：</label>
                                <input type="text" name="taskName"/>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="system:task:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:task:edit">-->
                    <!--<i class="fa fa-edit"></i> 修改-->
                <!--</a>-->
                <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:task:remove">-->
                    <!--<i class="fa fa-remove"></i> 删除-->
                <!--</a>-->
                <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:task:export">-->
                    <!--<i class="fa fa-download"></i> 导出-->
                <!--</a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:task:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:task:remove')}]];
        var prefix = ctx + "gs/task";



        $(function() {
            var options = {
                url: prefix + "/getTaskPublishing",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "任务",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '唯一编号',
                    visible: false
                },
                {
                    field: 'taskName',
                    title: '任务名称'
                },
                {
                    field: 'reportFormName',
                    title: '报表名称'
                },
                {
                    field: 'taskStartTime',
                    title: '(任务时限)开始时间'
                },
                {
                    field: 'taskEndTime',
                    title: '(任务时限)结束时间'
                },
                {
                    field: 'taskType',
                    title: '任务类型'
                },
                    {
                        field: 'enclosure',
                        title: '任务附件'
                    },
                    {
                        field: 'executor',
                        title: '任务执行人'
                    },
                {
                    field: 'auditMethod',
                    title: '审核方式'
                },
                {
                    field: 'taskState',
                    title: '任务状态'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.taskState=="已发布"){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="handleUpState()"><i class="fa fa-remove"></i>终止</a>');
                        }else if(row.taskState=="待发布"){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="edit"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="handleUpState()"><i class="fa fa-remove"></i>发布</a>');
                        }

                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function edit() {
            let url = prefix + "/edit";
            $.modal.openFull("编辑任务信息", url);
        }
    </script>
</body>
</html>